June 1996

Subdividing your hard disk for Solaris x86

Under most operating systems, you can subdivide your hard disks into logical pieces and use them in various ways. However, Solaris x86 allows you to have only one Solaris partition. This isn't ordinarily a problem, but there are a few occasions where youíd like to be able to subdivide a disk drive.

For example, suppose you have a machine on which you're doing development, and you're constantly installing Solaris on it. You don't necessarily want to subject your data to any risk while you're installing. If you're reverting to a previous version of Solaris, you may have to do some serious work to prepare the machine.

Alternatively, suppose your machine contains multiple operating systems, and you decide that you want to use it exclusively for Solaris. How can you reclaim the rest of the hard disk space on which the other operating systems reside?

In this article, we'll show you a technique that lets you create a UNIX file system on which you can use other fdisk partitions, so you can mount them with Solaris.

Danger! Warning! Beware!

It's important to note that, although Sun Microsystems provided this information, this procedure hasn't gone through any rigorous testing and isn't supported by Sun. So you can use this procedure at your own risk. (Sun's document ID for this procedure is 1540-02.) If you make any mistakes, it's possible to lose data on other partitions on your drive. So be careful!

All that being said and done, however, this technique doesn't seem to be harmful. As with any technique that can cause data loss if it goes awry, we strongly recommend that you back up your system before proceeding.

Background

As you may know, standard DOS hard drives provide a Master Boot Record (MBR) that contains the partitioning information for up to four disk partitions. Solaris, on the other hand, prefers its own method of subdividing the disk. On an IBM-PC clone, the BIOS uses this MBR to decide from which partition to boot. When you install Solaris, Solaris allows you to subdivide its partition into pieces that you can use for different file systems.

If you have a Sparc-based computer, then the MBR doesn't exist in the IBM-PC sense. Instead, Solaris manages the entire disk drive for you. Thus, this technique won't work on a Sparc-based computer.

Which partition(s) do you want to use for Solaris?

The first step you should perform is to run fdisk on the hard drive in question, so you can see which partitions exist. To run fdisk, you must specify the raw drive name for the drive you want to examine. For a SCSI-based drive, you'd type the command

$ fdisk /dev/rdsk/cCtTdDp0

where C is the controller number (typically 0), T is the target address (the same as the SCSI ID number), and D is the disk number (0 for standard hard drives).

If you're using an IDE drive, then you'd use the command

$ fdisk /dev/rdsk/cCdDp0

where C is the controller number (typically 0), and D is the disk number (0 for the master drive, 1 for the slave.)

Once you run fdisk, you'll see a screen similar to the one shown in Figure A. Now you have to determine which partition or partitions you want to use for Solaris. In this case, there are only two partitions. The first partition, with the type DOS­BIG, is a DOS partition that we no longer need, so we're going to put a Solaris ufs file system on it.

In order to put a file system on a raw partition, we need to find out which partition to use and how large the file system will be. In our case, we already know that we want to put the file system on partition 1, since we're going to reclaim our DOS partition. To determine how large the partition is, we need to find the line in the fdisk screen that tells the cylinder size. In Figure A, this line says: Cylinder size is 2079 (512 byte) blocks. Next, we must find the length of the partition, which in this case is 493 cylinders. Multiplying the number of cylinders (493) by the size of each cylinder (2,079), we find the size of the partition in blocks (1,024,947).

Now we have all the information we need to create the ufs file system on our partition. To do so, we must simply execute the mkfs command. This is the dangerous part! If you specify the wrong partition, you'll create a file system on the wrong partition, destroying the data that was there. If you get the length too long, your file system will run into the next partition on the disk, damaging data there. Please double-check your work before executing this command!

For a SCSI system, the format of the mkfs command will be

$ mkfs -F ufs /dev/rdsk/cCtTdDpP size

and for an IDE system, the format of the mkfs command will be

$ mkfs -F ufs /dev/rdsk/cCdDpP size

where C, T, and D are the same values they were when you executed the fdisk command earlier. The P value specifies on which partition we're going to create the file system. The size value specifies how many blocks are going to be in the file system. (In the fdisk command we used earlier, we used p0. That specified that we want to look at the partitioning information on the MBR.)

For our system, we're using a SCSI-based hard drive, with a SCSI ID of 0. Since we're going to put a ufs file system with 1,024,947 blocks on partition 1, we use the command

$ mkfs -F ufs /dev/rdsk/c0t0d0p1 1024947

When you run mkfs, you'll see a screen full of information about the process, as shown in Figure B. Don't worry if you get a warning like the one we got. It simply tells us that the last few sectors in the partition won't be accessible. You'll need to worry only if you get any errors.

Using the file system

Now you're ready to use the file system! All you need to do is tell Solaris to mount it. To do so, you can use the mount command, telling Solaris which disk to use. Before you mount a file system, you must have a mount point, meaning a directory that you want the file system to hold. For the purposes of our example, we'll create the directory /a, and then mount the file system on it, like this:

mkdir /a

mount /dev/dsk/c0t0d0p1 /a

That's all there is to it! Now, when you add information to directory /a, you're using a previously inaccessible partition. Once you've tested the partition, you can configure Solaris to automatically mount the file system on bootup, so you don't have to do it manually. If you use the df command, as we did in Figure C, you'll see that our new partition, nearly 500MB in size, was added at /a, just as we intended.

Notes

You can subdivide the standard Solaris partition into sections, so you can have multiple file systems in your Solaris partition. This technique won't allow you to subdivide the partitions you're reclaiming from other operating systems. Instead, each partition you reclaim will be a single file system. Since an IBM-PC system can have up to four physical partitions, you can have one Solaris partition and up to three raw ufs file systems.


[Return to Index for Inside Solaris - June 1996 Issue]

Copyright (c) 1996 The Cobb Group, a division of Ziff-Davis Publishing Company. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of Ziff-Davis Publishing Company is prohibited. The Cobb Group and The Cobb Group logo are trademarks of Ziff-Davis Publishing Company.

Inside Solaris is a publication of The Cobb Group.

1-800-223-8720